package cn.lili.controller;


import cn.hutool.core.util.ClassLoaderUtil;
import cn.hutool.json.JSONObject;
import cn.lili.listener.GoodsMessageListener;
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.dto.GoodsCompleteMessage;
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
import cn.lili.modules.member.entity.dos.FootPrint;
import cn.lili.modules.member.entity.dos.MemberEvaluation;
import cn.lili.modules.promotion.entity.dos.BaseStandardPromotions;
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams;
import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum;
import cn.lili.modules.search.entity.dto.EsGoodsIndexUpdatePromotionsDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 异常商品重推
 *
 * @author liushuai(liushuai711 @ gmail.com)
 * @version v4.0
 * @Description:
 * @since 2023/4/14 16:39
 */
@RestController
@RequestMapping("/consumer/goods")
@Api(tags = "异常商品API")
@RequiredArgsConstructor
@Slf4j
public class GoodsMessageRePush {


    private final GoodsMessageListener goodsMessageListener;

    @ApiOperation(value = "浏览商品")
    @GetMapping("/viewGoods")
    public void viewGoods(FootPrint footPrint) {
        goodsMessageListener.viewGoods(footPrint);
    }

    @ApiOperation(value = "生成商品索引")
    @GetMapping("/generatorGoodsIndex")
    public void generatorGoodsIndex(List<String> goodsIdsList) {
        log.info("=============goodsIdsList===",goodsIdsList.stream().collect(Collectors.joining(",")));
        goodsMessageListener.generatorGoodsIndex(goodsIdsList);
    }

    @ApiOperation(value = "生成全店铺商品索引")
    @GetMapping("/generatorStoreGoodsIndex")
    public void generatorStoreGoodsIndex(String storeId) {
        goodsMessageListener.generatorStoreGoodsIndex(storeId);
    }

    @ApiOperation(value = "重新生成商品索引")
    @GetMapping("/updateGoodsIndexPromotion")
    public void updateGoodsIndexPromotion(JSONObject jsonObject) {
        goodsMessageListener.updateGoodsIndexPromotion(jsonObject);
    }


    @ApiOperation(value = "删除促销索引")
    @GetMapping("/deleteGoodsIndexPromotion")
    public void deleteGoodsIndexPromotion(JSONObject jsonObject) {
        goodsMessageListener.deleteGoodsIndexPromotion(jsonObject);
    }

    @ApiOperation(value = "更新商品索引")
    @GetMapping("/updateGoodsIndexListener")
    public void updateGoodsIndexListener(String goodsIdStr) {
        goodsMessageListener.updateGoodsIndexListener(goodsIdStr);

    }

    @ApiOperation(value = "更新商品索引")
    @GetMapping("/updateGoodsIndexField")
    public void updateGoodsIndexField(String updateIndexFieldsJsonStr) {
        goodsMessageListener.updateGoodsIndexField(updateIndexFieldsJsonStr);

    }


    @ApiOperation(value = "删除商品")
    @GetMapping("/goodsDelete")
    public void goodsDelete(@RequestParam("goodsIds") List<String> goodsIds) {
        goodsMessageListener.goodsDelete(goodsIds);
    }


    @ApiOperation(value = "删除SKU")
    @GetMapping("/skuDelete")
    public void skuDelete(@RequestParam("skuIds") List<String> skuIds) {
        goodsMessageListener.skuDelete(skuIds);
    }

    @ApiOperation(value = "删除店铺商品")
    @GetMapping("/storeGoodsDelete")
    public void storeGoodsDelete(String storeId) {
        goodsMessageListener.storeGoodsDelete(storeId);
    }

    @ApiOperation(value = "商品评价")
    @GetMapping("/goodsCommentComplete")
    public void goodsCommentComplete(MemberEvaluation memberEvaluation) {
        goodsMessageListener.goodsCommentComplete(memberEvaluation);
    }

    @ApiOperation(value = "订单完成")
    @GetMapping("/goodsBuyComplete")
    public void goodsBuyComplete(List<GoodsCompleteMessage> goodsCompleteMessageList) {
        goodsMessageListener.goodsBuyComplete(goodsCompleteMessageList);
    }


}
